function counts(article) {
    article = article.trim().toUpperCase()
    let array = article.match(/[A-Z]+/g)
    article = " "+array.join("  ")+" ";
    let max = 0, word, num = 0, maxword = ''
    for(let i = 0; i < array.length; i++) {
        word = new RegExp(' ' + array[i] + ' ', 'g')
        num = article.match(word).length
        if(num > max) {
            max = num
            maxword = array[i]
        }
    }
    return maxword
}

let res = counts("Age has reached the end of the beginning of a word. May be guilty in his seems to passing a lot of different life became the appearance of the same day;");
console.log(res)